
var CommentInfoMediator = Objs("view.CommentInfoMediator",
	Mediator,
{

	initialize: function( name, viewComponent )
	{ 
		CommentInfoMediator.$super.initialize.call( this, name, viewComponent );
		this.VProxy = this.facade.retrieveProxy( ProxyNames.VEHICLE_PROXY );
		this.assetProxy = this.facade.retrieveProxy( ProxyNames.INITIAL_PROXY );
		this.registerListeners();
		
	},
	registerListeners: function()
	{   var commentInfoView = this.get();
		commentInfoView.addEventListener( CommentInfoPage.ADD_MESSAGE, this.addMessageHandler, this );
		
	},
	get: function()
	{
		return this.viewComponent;
	},
	unregisterListeners: function()
	{
	},
	addMessageHandler:function()
	{
	
		if(this.facade.hasMediator(MediatorNames.MESSAGE_POP_MEDIATOR)==false)
		{								
			var messagepopPage = new MessagepopPage();   
			var messagepopMediator = new MessagepopMediator( MediatorNames.MESSAGE_POP_MEDIATOR, messagepopPage);
			this.facade.registerMediator( messagepopMediator );
		}
	},
    
		
	

	
		listNotificationInterests: function()
	{
		return [
				NotificationNames.SETCOMVALUE,
				
				NotificationNames.ADD_MESSAGE_SUCCESS
		];
	},
    handleNotification: function( note )
	{ 
		
		switch (note.getName() )
		{ 
			case NotificationNames.SETCOMVALUE:
				this.setvalue();
				break;
			case NotificationNames.ADD_MESSAGE_SUCCESS:
				//document.getElementById("c_correspond_text").value="";
				vehicleSingle.messages=[];
				
				var messages=note.getBody().message;
				for(i=0;i<messages.length;i++)
				{
						vehicleSingle.messages.push(messages[i]);
				}
				this.setvalue();
				
				
				break;	
		}
	},
	setvalue:function()
	{
		document.getElementById("c_list_correspond").innerHTML = '';
		var meshtml=''
		for(var i=0;i<vehicleSingle.messages.length;i++)
		{ 
			 meshtml+="<div class='commentBox'> <div id=messagehead style='border-bottom:solid 1px #CCC'><strong>On " +vehicleSingle.messages[i].dateTime+ " " +vehicleSingle.messages[i].messageOwener+ " Wrote</strong></div><div id=messagedetail style='padding-bottom:10px;'>" +vehicleSingle.messages[i].message+ "</div></div>"; 
		}
		document.getElementById("c_list_correspond").innerHTML=meshtml;
		//document.getElementById("model-poplistcinfo").innerHTML =meshtml;
	}	
});

